package com.poi.demopoi.service.impl;

import com.poi.demopoi.domain.EmployeeDto;
import com.poi.demopoi.domain.EmployeeVO;
import com.poi.demopoi.service.WriterService;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Component
public class WriterExcelServiceImpl implements WriterService<EmployeeDto> {

    @Override
    public void write2Rows(List<EmployeeDto> financeStatisticsDTOList, Sheet sheet, Integer index) {
        if (CollectionUtils.isEmpty(financeStatisticsDTOList)){
            return;
        }

        for (int i = 0; i < financeStatisticsDTOList.size(); i++) {
            Row row = sheet.createRow(index++);
            EmployeeDto statisticsDTO = financeStatisticsDTOList.get(i);
            //todo
            row.createCell(0).setCellValue(statisticsDTO.getId());
            row.createCell(1).setCellValue(statisticsDTO.getName());
            row.createCell(2).setCellValue(statisticsDTO.getAge());
            row.createCell(3).setCellValue(statisticsDTO.getEmail());
        }
    }
}
